<template>
  <div>
    <el-dialog :title="dataInfo.name || ''" :visible.sync="dialogVisible" lock-scroll width="28%">
      <div class="dialog_div_new">
        <div class="dialog_middle">
          <svg-icon class="svg_icon" icon-class="prompt_red"></svg-icon>
          <div>
            <p>您确定要对账号：{{ account() }}进行{{ dataInfo.goodsType == 2 ? '系统数据恢复' : '反审' }}吗？<br />费用：{{ dataInfo.price || 0 }}元
            </p>
          </div>
        </div>
        <div class="dialog_bottom">
          <el-button type="primary" @click.stop="onConfirm">去支付</el-button>
          <el-button @click.stop="dialogVisible = false">取消</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import Vue from 'vue'
import { USER_INFO, USER_NAME, ACCOUNT_BOOK } from '@/store/mutation-types'
import { postAction, getAction } from '@/api/manage'
export default {
  data() {
    return {
      dialogVisible: false,
      dataInfo: {},
    }
  },
  methods: {
    account() {
      return Vue.ls.get(USER_NAME)
    },
    // 去支付
    onConfirm() {
      let accountBook = Vue.ls.get(ACCOUNT_BOOK)
      let accountId = accountBook && accountBook.id
      let params = {
        goodsId: this.dataInfo.id,
        goodsName: this.dataInfo.name,
        // goodsNumber: this.yearList[this.yearIndex].no,
        goodsType: this.dataInfo.goodsType,
        xghAccountBookId: accountId,
        orderMoney: this.dataInfo.price,
        // orderMoney: 0.01,
      }
      postAction('/XghAuthorizationCenter/xghAuthorizationCenterOrders/add', params).then(res => {
        if (res.code == 200) {
          this.$router.push({
            path: '/setting/buy/confirmPay',
            query: {
              id: res.result.id
            }
          })
        } else {
          this.$elMessage.error(res.message)
        }
      })
    },
  },
}
</script>

<style lang="scss" scoped>
::v-deep .el-dialog {
  margin-top: 33vh !important;
  border-radius: 0.187512rem;
  overflow: hidden;

  .el-dialog__body {
    padding: 0;
  }

  .el-dialog__header {
    width: 100%;
    height: 0.937559rem;
    box-sizing: border-box;
    padding: 0 0.375023rem;
    border-bottom: 1px solid #eeeeee;
    display: flex;
    align-items: center;
    justify-content: space-between;

    span {
      font-size: 15px;
      color: #666;
      font-weight: 600;
    }

    .el-dialog__headerbtn {
      position: static;

      .el-icon-close {
        color: #999;
        font-size: 23px;
      }
    }
  }
}

.dialog_div_new {
  width: 100%;
  height: 25vh;
  overflow: auto;
  background: #fff;

  .dialog_middle {
    width: 100%;
    height: calc(100% - 1.12507rem - .281268rem);
    box-sizing: border-box;
    padding: 0 .843803rem 0 0.937559rem;
    margin-top: .281268rem;
    display: flex;
    align-items: center;
    overflow: auto;

    .svg_icon {
      width: 0.787549rem;
      height: 0.787549rem;
      margin-top: -0.093756rem;
    }

    div {
      width: calc(100% - 0.787549rem);
      margin-left: 0.468779rem;
      box-sizing: border-box;

      p {
        width: 100%;
        font-size: 13px;
        font-family: PingFang SC;
        font-weight: 400;
        line-height: .412526rem;
        color: #666666;
        margin: 0;
      }
    }
  }

  .dialog_bottom {
    width: 100%;
    height: 1.12507rem;
    box-sizing: border-box;
    padding: 0 0.187512rem;
    display: flex;
    align-items: center;
    justify-content: center;

    ::v-deep .el-button {
      width: 1.12507rem;
      height: 0.562535rem;
      text-align: center;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 12px;
      border-radius: 0.093756rem;
      background: #fff;
      border: 1px solid #dddddd;
      color: #666666;
    }

    ::v-deep .el-button--primary {
      background: #1890ff;
      border-color: #1890ff;
      color: #fff;
      margin-left: 0.112507rem;
    }

    ::v-deep .el-button--default {
      margin-right: 0.112507rem;
    }
  }
}</style>